﻿<dialogs:DialogWindow x:Class="Modules.Listenings.Views.MoodDialog"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:localConverters="clr-namespace:Modules.Listenings.Converters"
             xmlns:converters="clr-namespace:Common.Dialogs.Converters;assembly=Common.Dialogs"
             xmlns:controls="clr-namespace:Common.Controls.Controls;assembly=Common.Controls"
             xmlns:dialogs="clr-namespace:Common.Dialogs;assembly=Common.Dialogs"
             xmlns:prismCommand="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
             mc:Ignorable="d" 
             x:Name="dialogWindow"
             WindowStyle="None" AllowsTransparency="True" ResizeMode="NoResize"
             Background="Transparent" WindowStartupLocation="CenterScreen"
             WindowResult="{Binding DialogResult}"
             Height="489" Width="508">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Common.Dialogs;component/Styles/CommonStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>

            <localConverters:HeaderTextConverter x:Key="HeaderTextConverter" EntityName="mood"/>
            <converters:InverseBoolConverter x:Key="InverseBoolConverter"/>
            <converters:RatingConverter x:Key="RatingConverter"/>
        </ResourceDictionary>
    </Window.Resources>
    <Grid x:Name="LayoutRoot"
          controls:BusyIndicatorBehavior.AddMargins="True" 
          controls:BusyIndicatorBehavior.BusyState="{Binding IsBusy}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Border x:Name="HeaderBorder" Grid.Row="0" BorderThickness="2,2,2,0" CornerRadius="10,10,0,0" BorderBrush="Black" Background="SteelBlue"
                MouseDown="HeaderBorder_MouseDown">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <StackPanel HorizontalAlignment="Left" Grid.Column="0">
                    <TextBlock Text="{Binding IsEditMode,Converter={StaticResource HeaderTextConverter}}" Style="{StaticResource DialogHeaderTextStyle}"/>
                </StackPanel>
                <StackPanel HorizontalAlignment="Right" Grid.Column="1">
                    <Button VerticalAlignment="Center" Margin="8" Style="{StaticResource CloseButtonStyle}"
                            prismCommand:Click.Command="{Binding CancelCommand}">
                        <Button.Content>
                            <Image Source="/Common.Dialogs;component/Images/305_Close_16x16_72.png" Width="12" Height="12"/>
                        </Button.Content>
                    </Button>
                </StackPanel>
            </Grid>
        </Border>
        <Border Grid.Row="1" BorderThickness="2,0,2,2" CornerRadius="0,0,4,4" BorderBrush="Black" Background="LightGray">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid x:Name="ContentLayout">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <TextBlock Text="Mood" Grid.Row="0" Grid.Column="0" Style="{StaticResource DialogLabelStyle}"/>
                    <TextBox Grid.Row="0" Grid.Column="1" Margin="{StaticResource DialogMargin}"
                             Text="{Binding Mood.Name,Mode=TwoWay,UpdateSourceTrigger=LostFocus,ValidatesOnExceptions=True}"/>

                    <TextBlock Text="Description" Grid.Row="1" Grid.Column="0" VerticalAlignment="Top" Style="{StaticResource DialogLabelStyle}"/>
                    <TextBox Grid.Row="1" Grid.Column="1" Margin="{StaticResource DialogMargin}" AcceptsReturn="True"
                                     Text="{Binding Mood.Description,Mode=TwoWay}"
                                     IsReadOnly="{Binding IsEditMode,Converter={StaticResource InverseBoolConverter}}"/>
                    <TextBlock Text="Comments" Grid.Row="2" Grid.Column="0" VerticalAlignment="Top" Style="{StaticResource DialogLabelStyle}"/>
                    <TextBox Grid.Row="2" Grid.Column="1" Margin="{StaticResource DialogMargin}" AcceptsReturn="True"
                                     Text="{Binding Mood.Comments,Mode=TwoWay}"
                                     IsReadOnly="{Binding IsEditMode,Converter={StaticResource InverseBoolConverter}}"/>
                    <TextBlock Text="Private marks" Grid.Row="3" Grid.Column="0" VerticalAlignment="Top" Style="{StaticResource DialogLabelStyle}"/>
                    <TextBox Grid.Row="3" Grid.Column="1" Margin="{StaticResource DialogMargin}" AcceptsReturn="True"
                                     Text="{Binding Mood.PrivateMarks,Mode=TwoWay}"
                                     IsReadOnly="{Binding IsEditMode,Converter={StaticResource InverseBoolConverter}}"/>
                </Grid>
                <StackPanel Grid.Row="1" HorizontalAlignment="Right" Orientation="Horizontal" Margin="12,0,0,12">
                    <Button x:Name="OkButton" Content="Ok" Width="75" IsDefault="True" Margin="6"
                            Style="{StaticResource DialogButtonStyle}"
                            prismCommand:Click.Command="{Binding SuccessCommand}"
                            prismCommand:Click.CommandParameter="{Binding ElementName=LayoutRoot}"
                            />
                    <Button x:Name="CancelButton" Content="Cancel" Width="75" IsDefault="True" Margin="6"
                            Style="{StaticResource DialogButtonStyle}"
                            prismCommand:Click.Command="{Binding CancelCommand}"
                            />
                </StackPanel>
            </Grid>
        </Border>
    </Grid>
</dialogs:DialogWindow>
